package com.cyx.mapper;

import com.cyx.pojo.User;
import org.mybatis.spring.SqlSessionTemplate;

public class UserMapperImpl implements UserMapper {

    //让外部将配置文件中的sqlSession 注入进来
    private SqlSessionTemplate sqlSession;

    public SqlSessionTemplate getSqlSession() {
        return sqlSession;
    }

    public void setSqlSession(SqlSessionTemplate sqlSession) {
        this.sqlSession = sqlSession;
    }

    @Override
    public User getUser(int id) {
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        return mapper.getUser(id);
    }

    @Override
    public int addUser(User user) {
        return sqlSession.getMapper(UserMapper.class).addUser(user);
    }

    @Override
    public int deleteUser(int userId) {
        return sqlSession.getMapper(UserMapper.class).deleteUser(userId);
    }
}
